package org.example.mybatis.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.example.mybatis.bean.Emp;

import java.util.List;

@Mapper
public interface EmpMapper {
    @Select("select * from emp where state=1")
    List<Emp> find();
    // ${}相当于+ 是连接符  #{}相当于? 是通配符
    @Insert("insert into emp values (null,#{ename},#{job},#{mgr},now(),#{sal},#{comm},#{deptNo},1)")
    boolean save(Emp emp);
    @Update("update emp set mgr=#{mgr},sal=#{sal} where empno=#{empNo}")
    boolean update(Emp emp);
    // 逻辑删除
    @Update("update emp set state = 0 where empno = #{id}")
    boolean delete(int id);

}
